<template>
	<view class="work-detail">
		<view class="work-detail-base">
			<view class="work-detail-base-title">{{ worksInfo.title }}</view>
			<view class="work-detail-base-price">
				<text>{{ worksInfo.workPrice }}</text>
				<text>{{ worksInfo.priceUnitName }}</text>
			</view>
			<view class="work-detail-base-tags">
				<view v-for="(item, index) in worksInfo.workTags" :key="index" class="work-detail-base-tags-item">{{ item }}</view>
			</view>
		</view>
		<view class="work-detail-confine">
			<view class="work-detail-confine-title" style="margin-top: 0;">职位简介</view>
			<view class="work-detail-confine-need">
				<view class="wdc-item">
					<text>招聘人数</text>
					<text>{{ worksInfo.needCount }}人</text>
				</view>
				<view class="wdc-item">
					<text>年龄限制</text>
					<text>{{ worksInfo.workAge }}周岁</text>
				</view>
				<view class="wdc-item">
					<text>招聘公司</text>
					<text>{{ worksInfo.companyName }}</text>
				</view>
				<view class="wdc-item">
					<text>工作地点</text>
					<text>{{ worksInfo.workProvinceName + worksInfo.workCityName + worksInfo.workAreaName + worksInfo.workAddress }}</text>
				</view>
			</view>
			<view class="work-detail-confine-title">职位详情</view>
			<view class="work-detail-confine-content">
				<view v-html="worksInfo.workContent"></view>
			</view>
		</view>
		<view class="work-detail-safe">
			<view class="work-detail-safe-title">安全提示</view>
			<view class="work-detail-safe-info">
				<view>1.平台兼职信息均由兼职合作伙伴提供，平台不参与协商，如有违法行为请及时报警处理。</view>
				<view>2.报名后会主动联系您，请注意甄别是否非官方平台。</view>
				<view>3.平台由济南历城天晴网络科技工作室研发，如有需要请致电18615538792。</view>
				<view>4.关注‘天晴软件’公众号，获取更多软件资讯信息。</view>
			</view>
		</view>
		<view class="work-detail-btns">
			<view @click="goEnroll" class="work-detail-btns-wrap">
				<view class="wdb-btn">立即报名</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				workTags: ['日结', '兼职'],
				content: `<p style="color: red;font-size: 12px;">我的乖乖</p>`,
				worksInfo: {},
			};
		},
		onLoad(option) {
			this.getWorksInfo(option.id);
		},
		methods: {
			/** 查询岗位详情 */ 
			getWorksInfo(id) {
				this.$http.get({
					url: this.$apis.getWorksInfo + '/' + id,
					noAuth: true,
				}).then(res => {
					console.log(res, '调用接口成功');
					if (res.code === 200) {
						if (res.data && res.data.workTags) {
							res.data.workTags = res.data.workTags.split(',');
						} else {
							res.data.workTags = [];
						}
						this.worksInfo = res.data;
					}
					
				}).catch(err => {
					console.log('调用接口失败：', err);
				})
			},
			goEnroll() {
				uni.navigateTo({
					url: '/pages/enroll/enroll?id=' + this.worksInfo.id
				});
			}
		}
	}
</script>

<style lang="scss">
	.work-detail {
		background-color: #f1f1f1;
		height: 100vh;
		padding: 20rpx;
		box-sizing: border-box;
		overflow-y: auto;
		
		&-base {
			background-color: #ffffff;
			padding: 30rpx;
			border-radius: 20rpx;
			
			&-title {
				font-size: 38rpx;
				font-weight: 600;
			}
			
			&-price {
				margin-top: 20rpx;
				color: #ff3e3e;
				font-weight: 600;
				
				> text:first-child {
					font-size: 34rpx;
				}
				
				> text:last-child {
					font-size: 28rpx;
				}
			}
			
			&-tags {
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				
				&-item {
					background-color: #4dbf88;
					color: #ffffff;
					margin-right: 10rpx;
					font-size: 24rpx;
					padding: 4rpx 6rpx;
				}
			}
		}
		
		&-confine {
			margin-top: 20rpx;
			background-color: #ffffff;
			padding: 30rpx;
			border-radius: 20rpx;
			
			&-title {
				font-size: 30rpx;
				color: #333333;
				margin: 20rpx 0;
			}
			
			&-need {
				font-size: 28rpx;
				
				.wdc-item {
					margin-top: 10rpx;
					
					> text:first-child {
						color: #999999;
					}
					
					> text:last-child {
						color: #333333;
						margin-left: 20rpx;
					}
					
				}
			}
			
			&-content {
				
				image {
					max-width: 60vw;
				}
			}
		}
		
		&-safe {
			margin-top: 20rpx;
			background-color: #ffffff;
			padding: 30rpx;
			border-radius: 20rpx;
			
			&-title {
				font-size: 30rpx;
				color: #333333;
				margin-bottom: 20rpx;
			}
			
			&-info {
				font-size: 24rpx;
				color: #999999;
			}
		}
		
		&-btns {
			height: 120rpx;
			
			&-wrap {
				height: 120rpx;
				width: 100%;
				position: fixed;
				bottom: 0;
				left: 0;
				background-color: #ffffff;
				box-shadow: 0 -6rpx 10rpx 0 rgba(0, 0, 0, 0.1);
				display: flex;
				align-items: center;
				justify-content: flex-end;
				
				.wdb-btn {
					width: 160rpx;
					height: 70rpx;
					background-color: #15B371;
					text-align: center;
					line-height: 70rpx;
					color: #ffffff;
					border-radius: 35rpx;
					font-size: 28rpx;
					box-shadow: 5rpx 5rpx 5rpx 0px rgba(0, 0, 0, 0.2);
					margin-right: 20rpx;
				}
			}
		}
	}

</style>
